package com.wz.utils.string;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class StringUtils {
    public static void main(String[] args) {
//        String regex = ",|，| ";
//        String[] res = "A, B, C， 你好， 世界".split(regex);
////        List<String> ids = Arrays.stream(res).sequential().filter(StringUtils::isNotBlank).collect(Collectors.toList());
//        System.out.print(" 是 ".trim());
//        System.out.println("你");


//        String regex = " ";
//        String quote = "01 中共党员";
//        extracted(regex, quote);

//        test2();
        test3();

    }

    private static String extracted(String regex, String str) {
        String[] values = str.split(regex);
        StringBuilder result = new StringBuilder();
        for (String value : values) {
            result = result.append(nullToString(value));
        }
        return result.toString();
    }

    private static String nullToString(String value) {
        return value == null ? "" : value;
    }

    public static void test2() {
        String test = new String("ab") + "c";
        String test2 = new String("abc");
        System.out.println(test == test2);
    }

    public static void test3() {
        String test = new String("ab") + "c";
        String test2 = new String("abc");
        String test3 = test.intern();
        String test4 = "abc";
        System.out.println(test == test2);
        System.out.println(test == test3);
        System.out.println(test == test4);
        System.out.println(test2 == test3);
        System.out.println(test2 == test4);
        System.out.println(test3 == test4);
    }
}
